package controllers

import (
	"gitee.com/pangxianfei/frame/http/controller/gincontroller"
	"gitee.com/pangxianfei/frame/library/tmaic"
	"gitee.com/pangxianfei/frame/request"
	"gitee.com/pangxianfei/frame/response"
	"gitee.com/pangxianfei/saas/services"

	requests "tmaic/login/http/request"
)

type Login struct {
	Controller.BaseController
}

func (this *Login) PostLogin(c request.Context) *response.JsonResult {
	var requestData requests.UserLogin

	if err := this.ValidateJSON(c, &requestData, true); err != nil {

		return response.JsonFail(err.Error())

	}

	if platformAdmin, token, err := services.LoginService.Login(c, requestData.Mobile, requestData.Password); err == nil {

		return response.JsonQueryData(tmaic.V{"admininfo": platformAdmin, "token": token})
	}

	return response.JsonFail("登陆失败,请核正之后再试")
}
